package com.kalix.training.hotlists.biz;

import com.kalix.framework.core.api.persistence.JsonData;
import com.kalix.framework.core.impl.biz.ShiroGenericBizServiceImpl;
import com.kalix.training.hotlists.api.biz.IHotlistsAnchorBeanService;
import com.kalix.training.hotlists.api.dao.IHotlistsAnchorBeanDao;
import com.kalix.training.hotlists.api.dto.HotlistsAnchorDTO;
import com.kalix.training.hotlists.entities.HotlistsAnchorBean;

import java.util.List;

public class HotlistsAnchorBeanServiceImpl extends ShiroGenericBizServiceImpl<IHotlistsAnchorBeanDao, HotlistsAnchorBean>
implements IHotlistsAnchorBeanService {
    /**
     * 推荐主播（关联表：用户表）
     * @return jsondata
     */
    @Override
    public JsonData getAllHotlistsAnchor() {
        String sql = "select t.id,t.identify,t.uid,u.name as uname,u.icon from mooc_hotlistsanchor t,sys_user u where u.id = t.uid ORDER BY t.identify";
        List<HotlistsAnchorDTO> list = dao.findByNativeSql(sql, HotlistsAnchorDTO.class);
        JsonData jsonData = new JsonData();
        jsonData.setData(list);
        jsonData.setTotalCount((long) list.size());
        return jsonData;
    }
}
